package com.iris.live.services.data.repositories;

import com.iris.live.services.data.models.报价交车表Model;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Date;
import java.util.List;


/**
 * Created by EngLee on 2016/8/14
 */
@Transactional
public interface 报价交车表Repository extends JpaRepository<报价交车表Model, Integer>, JpaSpecificationExecutor<报价交车表Model> {
    @Query("select m from 报价交车表Model m where m.编号 = ?1 ")
    报价交车表Model findby编号(int 编号 );

    @Modifying
    @Query("update  报价交车表Model a set a.合同签约日期=?2 where a.编号=?1")
    void updateDateById(int id, Date dt);

    @Modifying
    @Query("update  报价交车表Model a set a.开票时间=?2 where a.编号=?1")
    void updateInvoiceDateById(int id, Date dt);

    @Query("select m from 报价交车表Model m where m.vin = ?1 and m.交车日期 != null ")
    List<报价交车表Model> hasLeaveCarByVin(String vin );
}